namespace ShapesLib
{
    using System;
    using System.Collections.Generic;
    using System.Drawing;
    using System.Text;

    /// <summary>
    /// Class to be able to draw rectangles.
    /// </summary>
    public class Rectangle : Shape
    {
        #region Members

        /// <summary>
        /// Width of rectangle
        /// </summary>
        private int privateWidth;

        /// <summary>
        /// Height of rectangle
        /// </summary>
        private int privateHeight;

        #endregion

        #region constructor(s)
        
        /// <summary>
        /// Initializes a new instance of the <see cref="Rectangle"/> class.
        /// </summary>
        /// <param name="x">The x.</param>
        /// <param name="y">The y.</param>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        public Rectangle(int x, int y, int width, int height)
        {
            X = x;
            Y = y;
            this.Width = width;
            this.Height = height;
            this.FillColor = Color.Red; // Orange is a static member of class Color
        }

        #endregion

        #region Properities
        /// <summary>
        /// Gets or sets the width.
        /// </summary>
        /// <value>
        /// The width.
        /// </value>
        public int Width
        {
            get { return this.privateWidth; }
            set { this.privateWidth = value; }
        }

        /// <summary>
        /// Gets or sets the height.
        /// </summary>
        /// <value>
        /// The height.
        /// </value>
        public int Height
        {
            get { return this.privateHeight; }
            set { this.privateHeight = value; }
        }
        #endregion

        #region Methods
        /// <summary>
        /// Draws the specified g.
        /// </summary>
        /// <param name="g">The g.</param>
        public override void Draw(Graphics g)
        {
            SolidBrush solidBrush = new SolidBrush(FillColor);
            g.FillRectangle(solidBrush, X, Y, this.Width, this.Height);

            Pen myPen = new Pen(PenColor, PenWidth);
            g.DrawRectangle(myPen, X, Y, this.Width, this.Height);
        }

        /// <summary>
        /// Scales the specified factor.
        /// </summary>
        /// <param name="factor">The factor.</param>
        public override void Scale(double factor)
        {
            this.Width = (int)((double)this.Width * factor);
            this.Height = (int)((double)this.Height * factor);
        }

        /// <summary>
        /// Points the in shape.
        /// </summary>
        /// <param name="x">The x.</param>
        /// <param name="y">The y.</param>
        /// <returns>Returns true if point exists in shape.</returns>
        public override bool PointInShape(int x, int y)
        {
            if (x >= X && x < (X + this.Width) && y >= Y && y < (Y + this.Height))
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        #region Section3 method
        /// <summary>
        /// Draws for creation.
        /// </summary>
        /// <param name="g">The g.</param>
        public override void DrawForCreation(Graphics g)
        {
            SolidBrush solidBrush = new SolidBrush(Color.FromArgb(128, FillColor));
            g.FillRectangle(solidBrush, X, Y, this.Width, this.Height);

            Pen myPen = new Pen(PenColor, PenWidth);
            myPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
            g.DrawRectangle(myPen, X, Y, this.Width, this.Height);
        }

        #endregion

        #endregion
    }
}
